package com.chang.soul.service.imp;

import com.chang.soul.bean.ScaleBean;
import com.chang.soul.bean.ScaleQueryForm;
import com.chang.soul.dao.ScaleMapper;
import com.chang.soul.service.ScaleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ScaleServiceImp implements ScaleService {

    @Autowired
    ScaleMapper scaleMapper;

    @Override
    public boolean insertScale(ScaleBean scaleBean) {
       try {
           scaleMapper.insertScale(scaleBean);
       }catch (Exception e){
           System.out.println(e);
           return  false;
       }
       return true;
    }

    @Override
    public Integer getScaleCounts() {
        return scaleMapper.getScaleCounts();
    }

    @Override
    public List<ScaleBean> getAllScaleList(ScaleQueryForm scaleQueryForm) {
        return scaleMapper.getAllScaleList(scaleQueryForm);
    }

    @Override
    public Integer getCountByScaleList(ScaleQueryForm scaleQueryForm) {
        return scaleMapper.getCountByScaleList(scaleQueryForm);
    }

    @Override
    public boolean deleteScaleById(Integer id) {
        try{
            scaleMapper.deleteScaleById(id);

        }catch (Exception e){
            System.out.println(e);
            return false;
        }
        return true;
    }

    @Override
    public boolean updateScale(ScaleBean scaleBean) {
        try{
            scaleMapper.updateScale(scaleBean);
        }catch (Exception e){
            System.out.println(e);
            return false;
        }
        return true;
    }

    @Override
    public ScaleBean getScaleById(Integer id) {
        return scaleMapper.getScaleById(id);
    }
}
